package util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class CheckoutBirth {
//	public static boolean checkBirth(String birth){
//		String re = "^\\d{4}-\\d{1,2}-\\d{1,2}";
//		Pattern pattern = Pattern.compile(re);
//		Matcher matcher = pattern.matcher(birth);
//		if(matcher.find()){
//			return true;
//		}else{
//			return false;
//		}
//	}
	
	public static Date CheckedBirth(String birth){
		Date birthDate = null;
		String re = "^\\d{4}-\\d{1,2}-\\d{1,2}$";
		Pattern pattern = Pattern.compile(re);
		Matcher matcher = pattern.matcher(birth);
		if(matcher.find()){
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			try {
				birthDate = sdf.parse(birth);
			} catch (ParseException e) {
				return null;
			}
			return birthDate;
		}else{
			return null;
		}
	}

}
